//
//  EFOrderLogisticsInformationViewCell.m
//  EnjogFood
//
//  Created by guocheng on 2017/5/9.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFOrderLogisticsInformationViewCell.h"
#import "EFOrderLogisticsInformationViewItem.h"

@interface EFOrderLogisticsInformationViewCell()

@property(strong,nonatomic)UILabel* addressLabel;
@property(strong,nonatomic)UILabel* dateLabel;

@property(strong,nonatomic)UIView* leftTopLine;
@property(strong,nonatomic)UIImageView* leftCirCleIV;
@property(strong,nonatomic)UIView* leftBottomLine;

@property(strong,nonatomic)UIView* bottomLine;

@end

@implementation EFOrderLogisticsInformationViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor whiteColor];
        [self initView];
    }
    return self;
}

-(void)setObject:(EFOrderLogisticsInformationViewItem *)item{
    
    [self.addressLabel setText:item.address];
    [self.addressLabel sizeToFit];
    
    [self.dateLabel setText:item.time];
    [self.dateLabel sizeToFit];
    
    if(item.bFirst){
        self.leftTopLine.hidden = true;
        self.leftBottomLine.hidden = false;
        self.addressLabel.textColor = kBlack333;
        [self.leftCirCleIV setImage:IMG(@"latest_icon_Logistics")];
        self.leftCirCleIV.width = 14;
        self.leftCirCleIV.height = 14;
        
    }else if(item.bLast){
        self.leftTopLine.hidden = false;
        self.leftBottomLine.hidden = true;
        self.addressLabel.textColor = kBlack999;
        [self.leftCirCleIV setImage:IMG(@"past_icon_Logistics")];
        self.leftCirCleIV.width = 7;
        self.leftCirCleIV.height = 7;
    }else{
        self.leftTopLine.hidden = false;
        self.leftBottomLine.hidden = false;
        self.addressLabel.textColor = kBlack999;
        [self.leftCirCleIV setImage:IMG(@"past_icon_Logistics")];
        self.leftCirCleIV.width = 7;
        self.leftCirCleIV.height = 7;
    }
}

-(void)initView{
    [self.contentView addSubview:self.leftTopLine];
    [self.contentView addSubview:self.leftCirCleIV];
    [self.contentView addSubview:self.leftBottomLine];
    [self.contentView addSubview:self.addressLabel];
    [self.contentView addSubview:self.dateLabel];
    [self.contentView addSubview:self.bottomLine];
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.leftTopLine.left = 26;
    self.leftTopLine.top = 0;
    self.leftTopLine.width = 1;
    self.leftTopLine.height = 20;
    
    
    self.leftCirCleIV.left = 27 - self.leftCirCleIV.width/2;
    self.leftCirCleIV.top = self.leftTopLine.bottom;
    
    
    self.leftBottomLine.left = 26;
    self.leftBottomLine.top = self.leftCirCleIV.bottom;
    self.leftBottomLine.width = 1;
    self.leftBottomLine.height = 80 - self.leftTopLine.height - self.leftCirCleIV.width;

    self.addressLabel.left = 46;
    self.addressLabel.top = 19;
    self.addressLabel.width = kScreenWidth - 46 - 21;
    self.addressLabel.height = 15;
    
    self.dateLabel.left = 46;
    self.dateLabel.top = self.addressLabel.bottom + 5;
    self.dateLabel.width = kScreenWidth - 46 - 21;
    self.dateLabel.height = 15;
    
    self.bottomLine.left =  46;
    self.bottomLine.top  = self.height - 1;
    self.bottomLine.width =  kScreenWidth - 46 - 21;
    self.bottomLine.height = 1;
}

-(UIView *)leftTopLine{
    if(_leftTopLine == NULL){
        _leftTopLine = [[UIView alloc] init];
        _leftTopLine.backgroundColor = RGBCOLOR(0xF4F4F4);
    }
    return _leftTopLine;
}


-(UIImageView*)leftCirCleIV{
    if(_leftCirCleIV == NULL){
        _leftCirCleIV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 14, 14)];
    }
    return _leftCirCleIV;
}

-(UIView *)leftBottomLine{
    if(_leftBottomLine == NULL){
        _leftBottomLine = [[UIView alloc] init];
        _leftBottomLine.backgroundColor = RGBCOLOR(0xF4F4F4);
    }
    return _leftBottomLine;
}

-(UILabel *)addressLabel{
    if(_addressLabel == NULL){
        _addressLabel = [[UILabel alloc] init];
        _addressLabel.font = [UIFont systemFontOfSize:13];
        _addressLabel.textColor = kBlack333;
        _addressLabel.lineBreakMode = NSLineBreakByTruncatingTail;
    }
    return _addressLabel;
}

-(UILabel *)dateLabel{
    if(_dateLabel == NULL){
        _dateLabel = [[UILabel alloc] init];
        _dateLabel.font = [UIFont systemFontOfSize:13];
        _dateLabel.textColor = kBlack999;
        _dateLabel.lineBreakMode = NSLineBreakByTruncatingTail;
    }
    return _dateLabel;
}

-(UIView *)bottomLine{
    if(_bottomLine == NULL){
        _bottomLine = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth - 46 - 21, 1)];
        _bottomLine.backgroundColor = RGBCOLOR(0xECECEC);
    }
    return _bottomLine;
}

@end
